package com.xnyzc.lhy.mis.service.impl.punishment;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.IDUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.mis.entity.punishment.OaDUserPunishmentImportrecord;
import com.xnyzc.lhy.mis.mapper.punishment.OaDUserPunishmentImportrecordMapper;
import com.xnyzc.lhy.mis.service.punishment.IOaDUserPunishmentImportrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 司机处罚导入记录 服务实现类
 * </p>
 *
 * @author cuixiaojian
 * @since 2019-10-27
 */
@Service
public class OaDUserPunishmentImportrecordServiceImpl extends ServiceImpl<OaDUserPunishmentImportrecordMapper, OaDUserPunishmentImportrecord> implements IOaDUserPunishmentImportrecordService {
    @Autowired
    private OaDUserPunishmentImportrecordMapper oaDUserPunishmentImportrecordMapper;

    @Override
    public Rv addOaDUserPunishmentImportrecord(OaDUserPunishmentImportrecord oaDUserPunishmentImportrecord) {
        oaDUserPunishmentImportrecord.setImportrecordId(IDUtil.nextId());
        Long sysUserId = TokenUtil.getTokenUserId();
        oaDUserPunishmentImportrecord.setOperationId(sysUserId);
        oaDUserPunishmentImportrecord.setCreateTime(new Date());
        oaDUserPunishmentImportrecordMapper.insert(oaDUserPunishmentImportrecord);
        return  Rv.wrap(EErrorCode.success);
    }

    @Override
    public Rv queryOaDUserPunishmentImportrecord(Integer pageSize, Integer current) {
        IPage iPage = new Page();
        iPage.setSize(pageSize);
        iPage.setCurrent(current);
        List<OaDUserPunishmentImportrecord> importrecords  = oaDUserPunishmentImportrecordMapper.queryOaDUserPunishmentImportrecord(iPage);
        iPage.setRecords(importrecords);
        return  Rv.wrap(EErrorCode.success,iPage);
    }
}
